import 'package:flutter/material.dart';
import 'package:yurun_smartmerchants/page/Tallied_page.dart';
import 'package:yurun_smartmerchants/page/tobetall_page.dart';
import 'package:yurun_smartmerchants/res/colours.dart';
import 'package:yurun_smartmerchants/utils/app_size.dart';

import 'approach_forecast_page.dart';


class TallyManagement extends StatefulWidget {
  @override
  _TallyManagementPageState createState() =>
      _TallyManagementPageState();
}

class _TallyManagementPageState extends State<TallyManagement>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  PageController _pageController = PageController();
  List<String> titles = ["待理货", "已理货"];

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: titles.length, vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
    _pageController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text('理货管理',
            style: TextStyle(fontSize: 18, color: Colours.app_words)),
        backgroundColor: Colours.title_bg,
        brightness: Brightness.light,
        iconTheme: IconThemeData(color: Colours.app_words),
        bottom: TabBar(
          tabs: <Widget>[
            Tab(
              text: titles[0],
            ),
            Tab(
              text: titles[1],
            ),
          ],
          controller: _tabController,
          indicatorColor: Colours.color_dd4b39,
          labelColor: Colours.color_dd4b39,
          unselectedLabelColor: Colours.color_434343,
          indicatorSize: TabBarIndicatorSize.label,
          indicatorWeight: 2,
          onTap: (index) {
            _pageController.jumpToPage(index);
          },
        ),
      ),
      resizeToAvoidBottomPadding: false,
      body: PageView(
        controller: _pageController,
        children: pages,
        onPageChanged: (index) {
          _tabController.animateTo(index);
        },
      ),
    );
  }

  final List<Widget> pages = <Widget>[
    TobeTallyList(),
    TalliedList()
  ];
}